finding absolute max and min on open interval